package com.example.demo.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Slf4j
@Service
public class ChatMessageService extends AbstractChatMessageService<String> {

    @Autowired
    private RedisMessageSender redisMessageSender;

    @Autowired
    private RedisService redisService;

    /**
     * 发布订阅
     * @param message
     */
    @Override
    public void sendMessage(String message) {
        redisMessageSender.sendMessage(message);
    }


    /**
     * 队列
     * @param message
     */
    public void pushMessage(String message) {
        redisService.lleftPush("push_message", message);
    }

    public void send2UserMessage(String message) {
        redisService.lrightPop("push_message");
        log.info("send2UserMessage message:{}", message);
    }
}
